import RedVo from "./RedVo";
/**author:yebinx email:yebinx@21cm.com*/
export default class RedManager{
    private static redDic:any={};

    public static register(_type:string,_red:any,_caller:any=null,_methed:Function=null,_param=null){
        let tvo:RedVo = this.redDic[_type];
        if(!tvo){
            tvo = new RedVo(_type);
            tvo.add(_red,_caller,_methed,_param);
            this.redDic[_type]=tvo;
        }
        else{
            tvo.add(_red,_caller,_methed);
        }
    }

    public static remove(_type:string,_red:any){
        let tvo:RedVo = this.redDic[_type];
        if(tvo)tvo.remove(_red);
    }

    public static updateAll(){
        for(let key in this.redDic){
            this.redDic[key].updateAll();
        }
    }

    public static update(_type:string){
        let tvo:RedVo = this.redDic[_type];
        if(tvo)tvo.updateAll();
    }
    /**强制设置状态*/
    public static updateSt(_type:string,_show:boolean){
        let tvo:RedVo = this.redDic[_type];
        if(tvo)tvo.updateSt(_show);
    }
}